/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package ddnsclient;

/**
 *
 * @author dvtrung
 */
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.InetAddress;
import java.net.Socket;
import java.net.UnknownHostException;

/**
 *
 * @author MINHHOANG
 */
public class MySendingInformation
{
    public boolean Send()
    {

        LoginGUI login = new LoginGUI();
        //RunningGUI running = new RunningGUI();
        try {
            //InetAddress myComputer = InetAddress.getLocalHost();
           
            String sendMessage = login.getUsername() + "-101-" + Main.revision++ + "-" + Main.host;
            //send host
            Main.pw.println(sendMessage);
            Main.pw.flush();
            String revMessage = Main.br.readLine();
            //check permission
            if(!revMessage.startsWith(login.getUsername() + "-205"))
                return false;
            sendMessage = login.getUsername() + "-102-" + Main.revision++ + "-" + Main.newIP;
            Main.pw.println(sendMessage);
            Main.pw.flush();
            //get result
            revMessage = Main.br.readLine();
            if(!revMessage.startsWith(login.getUsername() + "-203"))
                return false;
        } catch (UnknownHostException ex) {
            return false;
            //Logger.getLogger(MySendingInformation.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
            return  false;
            //Logger.getLogger(MySendingInformation.class.getName()).log(Level.SEVERE, null, ex);
        }
        return true;
    }
}
